<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>进程与线程：数字世界的舞者</title>
    <link rel="stylesheet" href="https://cdn.staticfile.org/font-awesome/6.4.0/css/all.min.css">
    <link rel="stylesheet" href="https://cdn.staticfile.org/tailwindcss/2.2.19/tailwind.min.css">
    <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/mermaid@latest/dist/mermaid.min.js"></script>
    <style>
        body {
            font-family: 'Noto Sans SC', Tahoma, Arial, Roboto, "Droid Sans", "Helvetica Neue", "Droid Sans Fallback", "Heiti SC", "Hiragino Sans GB", Simsun, sans-serif;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            min-height: 100vh;
        }
        
        .hero-gradient {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        }
        
        .card-hover {
            transition: all 0.3s ease;
        }
        
        .card-hover:hover {
            transform: translateY(-5px);
            box-shadow: 0 20px 40px rgba(0,0,0,0.1);
        }
        
        .text-gradient {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
            background-clip: text;
        }
        
        .drop-cap {
            float: left;
            font-size: 4rem;
            line-height: 1;
            font-weight: 700;
            margin-right: 0.5rem;
            margin-top: -0.2rem;
            color: #667eea;
            font-family: 'Noto Serif SC', serif;
        }
        
        .section-divider {
            position: relative;
            text-align: center;
            margin: 4rem 0;
        }
        
        .section-divider::before {
            content: '';
            position: absolute;
            top: 50%;
            left: 0;
            right: 0;
            height: 1px;
            background: linear-gradient(to right, transparent, #e5e7eb, transparent);
        }
        
        .section-divider i {
            position: relative;
            background: white;
            padding: 0 1rem;
            color: #9ca3af;
        }
        
        @keyframes float {
            0% { transform: translateY(0px); }
            50% { transform: translateY(-10px); }
            100% { transform: translateY(0px); }
        }
        
        .float-animation {
            animation: float 3s ease-in-out infinite;
        }
        
        .mermaid {
            display: flex;
            justify-content: center;
            margin: 2rem 0;
        }
    </style>
</head>
<body>
    <!-- Hero Section -->
    <section class="hero-gradient text-white py-20 px-6">
        <div class="max-w-6xl mx-auto text-center">
            <h1 class="text-5xl md:text-7xl font-bold mb-6 animate-pulse">
                <i class="fas fa-microchip mr-4"></i>进程与线程
            </h1>
            <p class="text-2xl md:text-3xl font-light mb-8">数字世界的优雅舞者</p>
            <div class="flex justify-center space-x-8 text-lg">
                <div class="float-animation">
                    <i class="fas fa-theater-masks text-4xl mb-2"></i>
                    <p>独立剧场</p>
                </div>
                <div class="float-animation" style="animation-delay: 0.5s;">
                    <i class="fas fa-users text-4xl mb-2"></i>
                    <p>协同舞者</p>
                </div>
                <div class="float-animation" style="animation-delay: 1s;">
                    <i class="fas fa-sync-alt text-4xl mb-2"></i>
                    <p>完美配合</p>
                </div>
            </div>
        </div>
    </section>

    <!-- Main Content -->
    <main class="bg-white">
        <div class="max-w-5xl mx-auto px-6 py-16">
            
            <!-- Introduction -->
            <section class="mb-16">
                <p class="text-lg leading-relaxed text-gray-700">
                    <span class="drop-cap">在</span>计算机的世界里，有两位主角常常上演着精彩的表演——线程和进程。它们就像是舞台上的演员和编舞，共同演绎着计算机的数字舞蹈。让我们以一个轻松的对比，揭开线程与进程的神秘面纱。
                </p>
            </section>

            <!-- Process Section -->
            <section class="mb-16">
                <div class="card-hover bg-gradient-to-r from-purple-50 to-pink-50 rounded-2xl p-8 shadow-lg">
                    <h2 class="text-3xl font-bold mb-6 flex items-center">
                        <i class="fas fa-building text-purple-600 mr-4"></i>
                        什么是进程？
                    </h2>
                    <p class="text-lg leading-relaxed text-gray-700">
                        首先，我们来认识一下进程。在计算机中，进程就像是一场独立的舞台剧，它包含了程序的执行、数据的存储和系统资源的分配。每个进程都是独立的，有自己的任务和动作，就如同舞台上的一场表演。
                    </p>
                    <div class="mt-6 grid grid-cols-3 gap-4 text-center">
                        <div class="bg-white rounded-lg p-4 shadow">
                            <i class="fas fa-memory text-3xl text-purple-600 mb-2"></i>
                            <p class="font-semibold">独立内存</p>
                        </div>
                        <div class="bg-white rounded-lg p-4 shadow">
                            <i class="fas fa-shield-alt text-3xl text-purple-600 mb-2"></i>
                            <p class="font-semibold">资源隔离</p>
                        </div>
                        <div class="bg-white rounded-lg p-4 shadow">
                            <i class="fas fa-tasks text-3xl text-purple-600 mb-2"></i>
                            <p class="font-semibold">独立执行</p>
                        </div>
                    </div>
                </div>
            </section>

            <!-- Thread Section -->
            <section class="mb-16">
                <div class="card-hover bg-gradient-to-r from-blue-50 to-green-50 rounded-2xl p-8 shadow-lg">
                    <h2 class="text-3xl font-bold mb-6 flex items-center">
                        <i class="fas fa-user-friends text-blue-600 mr-4"></i>
                        什么是线程？
                    </h2>
                    <p class="text-lg leading-relaxed text-gray-700">
                        现在，让我们转而关注线程。线程是进程中的更小的单位，可以理解为舞台上的独立舞者。一个进程中可以包含多个线程，它们共享进程的资源，但又能够独立执行不同的任务，就像是一场舞蹈中的多位舞者。
                    </p>
                    <div class="mt-6 grid grid-cols-3 gap-4 text-center">
                        <div class="bg-white rounded-lg p-4 shadow">
                            <i class="fas fa-share-alt text-3xl text-blue-600 mb-2"></i>
                            <p class="font-semibold">资源共享</p>
                        </div>
                        <div class="bg-white rounded-lg p-4 shadow">
                            <i class="fas fa-feather-alt text-3xl text-blue-600 mb-2"></i>
                            <p class="font-semibold">轻量级</p>
                        </div>
                        <div class="bg-white rounded-lg p-4 shadow">
                            <i class="fas fa-exchange-alt text-3xl text-blue-600 mb-2"></i>
                            <p class="font-semibold">快速切换</p>
                        </div>
                    </div>
                </div>
            </section>

            <!-- Visualization -->
            <section class="mb-16">
                <div class="section-divider">
                    <i class="fas fa-chart-network"></i>
                </div>
                <h2 class="text-3xl font-bold text-center mb-8 text-gradient">进程与线程的关系图</h2>
                <div class="mermaid">
                    graph TD
                        A[操作系统] --> B[进程1]
                        A --> C[进程2]
                        A --> D[进程3]
                        B --> E[线程1.1]
                        B --> F[线程1.2]
                        B --> G[线程1.3]
                        C --> H[线程2.1]
                        C --> I[线程2.2]
                        D --> J[线程3.1]
                        
                        style A fill:#667eea,stroke:#fff,stroke-width:2px,color:#fff
                        style B fill:#9f7aea,stroke:#fff,stroke-width:2px,color:#fff
                        style C fill:#9f7aea,stroke:#fff,stroke-width:2px,color:#fff
                        style D fill:#9f7aea,stroke:#fff,stroke-width:2px,color:#fff
                        style E fill:#a78bfa,stroke:#fff,stroke-width:2px,color:#fff
                        style F fill:#a78bfa,stroke:#fff,stroke-width:2px,color:#fff
                        style G fill:#a78bfa,stroke:#fff,stroke-width:2px,color:#fff
                        style H fill:#a78bfa,stroke:#fff,stroke-width:2px,color:#fff
                        style I fill:#a78bfa,stroke:#fff,stroke-width:2px,color:#fff
                        style J fill:#a78bfa,stroke:#fff,stroke-width:2px,color:#fff
                </div>
            </section>

            <!-- Differences -->
            <section class="mb-16">
                <h2 class="text-3xl font-bold mb-8 text-center">
                    <i class="fas fa-balance-scale text-purple-600 mr-4"></i>
                    进程与线程的区别
                </h2>
                <div class="grid md:grid-cols-2 gap-6">
                    <div class="card-hover bg-white rounded-xl p-6 shadow-lg border-l-4 border-purple-600">
                        <h3 class="text-xl font-bold mb-3 flex items-center">
                            <i class="fas fa-database text-purple-600 mr-3"></i>
                            资源占用
                        </h3>
                        <p class="text-gray-700">进程是独立的资源单位，拥有自己的内存空间和系统资源，而线程共享进程的资源。这就好比舞台上的不同剧场，每个进程有自己的舞台，而线程则共享同一个舞台。</p>
                    </div>
                    
                    <div class="card-hover bg-white rounded-xl p-6 shadow-lg border-l-4 border-blue-600">
                        <h3 class="text-xl font-bold mb-3 flex items-center">
                            <i class="fas fa-lock text-blue-600 mr-3"></i>
                            独立性
                        </h3>
                        <p class="text-gray-700">进程是相互独立的，一个进程的崩溃不会影响其他进程。而线程在同一进程中是共享资源的，一个线程的错误可能导致整个进程的崩溃，就像是一位舞者摔倒可能引起整场舞蹈的混乱。</p>
                    </div>
                    
                    <div class="card-hover bg-white rounded-xl p-6 shadow-lg border-l-4 border-green-600">
                        <h3 class="text-xl font-bold mb-3 flex items-center">
                            <i class="fas fa-comments text-green-600 mr-3"></i>
                            通信
                        </h3>
                        <p class="text-gray-700">不同进程之间通信相对复杂，需要使用特殊的机制，比如管道、消息队列等。而线程之间可以直接共享进程的数据，通信更加简单直接，就如同舞蹈中的默契配合。</p>
                    </div>
                    
                    <div class="card-hover bg-white rounded-xl p-6 shadow-lg border-l-4 border-pink-600">
                        <h3 class="text-xl font-bold mb-3 flex items-center">
                            <i class="fas fa-rocket text-pink-600 mr-3"></i>
                            创建与销毁
                        </h3>
                        <p class="text-gray-700">创建和销毁进程的开销较大，而线程的创建和销毁相对轻量级。这就好比一场大型演出结束后，整个剧组（进程）解散和重新组建的成本相对较高，而舞蹈中的个别舞者（线程）可以随时加入或退出。</p>
                    </div>
                </div>
            </section>

            <!-- Why Section -->
            <section class="mb-16">
                <h2 class="text-3xl font-bold mb-8 text-center">
                    <i class="fas fa-question-circle text-purple-600 mr-4"></i>
                    为什么需要线程和进程？
                </h2>
                <div class="space-y-6">
                    <div class="flex items-start space-x-4">
                        <div class="flex-shrink-0 w-12 h-12 bg-purple-600 rounded-full flex items-center justify-center text-white font-bold">
                            <i class="fas fa-chart-line"></i